package uk.co.cocking.getinline2.pipeline.transformers;

import java.util.ArrayList;
import java.util.List;

import org.hamcrest.Matcher;


public class Filter<T> extends AbstractTransformer<T, T> {

   private final Matcher<? super T> matcher;

   public Filter(Matcher<? super T> predicate) {
       this.matcher = predicate;
   }

   public List<T> transform(T item) {
	   List<T> zeroOrOneItems = new ArrayList<T>();
      if (matcher.matches(item)) {
         zeroOrOneItems.add(item);
      }
      return zeroOrOneItems;
   }

}
